declare @totalamt money
declare @noofyear int
declare @interest1 float
declare @interest2 float
declare @interest3 float
declare @interest4 float
declare @interestamt float
declare @noofperiod int
declare @outstandamt money
declare @curperiod int

set @totalamt = 300000.00
set @noofyear = 30
set @interest1 = 1.08
set @interest2 = 1.338
set @interest3 = 1.388
set @interest4 = 1.5
set @interestamt = 0.0
set @curperiod = 1
set @noofperiod = @noofyear * 12
set @outstandamt = @totalamt

select ((@totalamt*1.078)/100) [INTEREST ONE YEAR]
select ((@totalamt*1.078)/100) * 30 [INTEREST 30 YEARS]
select ((@totalamt*1.078)/100)/12.00 [INTEREST ONE MONTH]
select ((@totalamt*(1.078/12))/100) [INTEREST ONE MONTH TWO]

select @totalamt + ((@totalamt*1.078)/100) * 30 [Total Amount Plus Interest]
select (@totalamt + ((@totalamt*1.078)/100) * 30)/ 30
select ((@totalamt + ((@totalamt*1.078)/100) * 30)/ 30)/12

declare @i int
declare @totalpayment float
set @i = 12
set @outstandamt = @totalamt
set @totalpayment = 0

WHILE(@i > 0)
BEGIN
	set @totalpayment = @totalpayment + ((@outstandamt + ((@outstandamt*1.078)/100) * 30)/ 30)/12
	set @outstandamt = @outstandamt - @totalpayment
	set @i = @i - 1
END

select @totalpayment


--WHILE(@outstandamt > 0)
--BEGIN
--	IF @curperiod = 1
--		BEGIN
--			set @interestamt = ((@totalamt*@interest1)/100)/12.00
--		END
--END


